from urllib.request import urlopen

url="http://www.baidu.com/"

# 使用 urlopen 打开指定的 URL
resp=urlopen(url)
# 打印响应对象 resp
# print(resp)

# 读取响应的内容并打印
print(resp.read())

# print(resp.read().decode("utf-8"))

# with open("mybaidu.html",mode="w",encoding="utf-8") as f:
#     f.write(resp.read().decode("utf-8"))
